<?php
/**
 * 医生信息管理控制器
 * Created by PhpStorm.
 * User: change
 * Date: 2016/12/22
 * Time: 22:17
 */

namespace Admin\Controller;
use Admin\Model\AerainfoModel;
use Base\Controller\CurdController;
use Library\BmobSms;
use Library\UploadFile;
class UserFeedbackinfoController extends CurdController
{
        public function __construct()
    {
        parent::__construct(true, true, array(
            'input_name' => 'coverFile',//文本框name
            'save_path' => 'doctorcover',//保存路径
            'data_field' => 'cover'//数据库字段
        ));
     }

    protected function getAll()
    {

        if($_REQUEST['keyword']){
            $map['phonenum'] = array('like','%'.$_REQUEST['keyword'].'%');
            $map['comment']  = array('like', '%'.$_REQUEST['keyword'].'%');
            $map['_logic'] = 'or';
            $where['_complex'] = $map;
        }
   
        if($_REQUEST['selects']){
            $limit=$_REQUEST['selects'];
        }else{
            $limit=20;
        }
        $data = $this->model->pageToView($limit, true,$where);
        $this->assign("page", $data['page']);
        $this->assign("list", $data['list']);
    }
    /**
     * 短信验证码
     */
    public  function sendmsg($id){
        $datas=$this->model->where(array('id'=>$id))->find();
        $phonenum =$datas['phonenum'];
//        $replay=htmlspecialchars_decode($datas['replay']);
        $bmobSms = new  BmobSms();
        $res = $bmobSms->sendSmsVerifyCode("$phonenum", "YZ_Replay"); //发送短信
        if($res->smsId  ){
            $this->success('发送成功');
        }else{
            $this->success('短信发送失败');
        }
    }
	    public function del($id)
    {
        $arr = explode(',', $id);
        $i = 0;
        foreach ($arr as $k => $v) {
            if (!$v) {
                continue;
            }
            $this->model->where('id=' . $v)->delete();

        }
        $i++;
        $this->success('删除' . $i . '条数据', $this->urlConfig['del_success']);
    }

}